from django.contrib import admin
from apps.derive_keys_management.models import DeriveKey, DeriveKeyAuditLog


@admin.register(DeriveKey)
class DeriveKeyAdmin(admin.ModelAdmin):
    list_display = ['app_id', 'key_id', 'algorithm', 'purpose', 'derive_id', 'status', 'created_at', 'expires_at']
    list_filter = ['algorithm', 'purpose', 'status', 'created_at']
    search_fields = ['key_id', 'derive_id', 'root_key_id']
    readonly_fields = ['key_id', 'version', 'created_at', 'updated_at']
    ordering = ['-created_at']


@admin.register(DeriveKeyAuditLog)
class DeriveKeyAuditLogAdmin(admin.ModelAdmin):
    list_display = ['key_id', 'operation', 'operator', 'operation_time', 'ip_address']
    list_filter = ['operation', 'operation_time']
    search_fields = ['key_id', 'operator', 'ip_address']
    readonly_fields = ['operation_time']
    ordering = ['-operation_time']
